package com.expressage.controller;

import com.expressage.po.CityAddress;
import com.expressage.service.CityAddressService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * 首页控制器
 */
@Controller
public class IndexController {

    Logger logger =Logger.getLogger(IndexController.class);
    @Autowired
    CityAddressService cityAddressService;
    @RequestMapping("/")
    public String index(){
        logger.info("进入了首页控制器");
        return "redirect:index.action";
    }
    @RequestMapping("/index")
    public String showInfo(Model model){
        logger.info("进入了首页查询控制器");
        List<CityAddress> list=new ArrayList<>();
        list =cityAddressService.findAll();
        for (CityAddress c:list) {
            logger.info(c.getCityid()+"\t"+c.getCityname());
        }
        model.addAttribute("list",list);
        return "jspbefore/index";
    }
    @RequestMapping("/main")
    public String main(){
        return "jspafter/main";
    }

    @RequestMapping("/news")
    public String tonews(){
        return "jspbefore/news";
    }

    @RequestMapping("/service")
    public String toservice(){
        return "jspbefore/service";
    }

    @RequestMapping("/product")
    public String toproduct(){
        return "jspbefore/product";
    }

    @RequestMapping("/about")
    public String toabout(){
        return "jspbefore/about";
    }
}
